/*********************
* Author:Dzlua
* QQ:505544956
* time:2016/12/02
*/
#include "LuaLink.h"
#include "../../utilities/Log.h"

#ifdef EDUI_USE_LUAPLUS

EDUI_NAMESPACE_BEGIN

#define CObjPtr (Link::ToLink(m_cobj))

void* LuaLink::GetInterface(void* data)
{
    if (!data) return 0;
    LuaLink* link = new LuaLink((Link*)data);
#ifdef EDUI_TEST_NEW_DELETE
    ++m_newdeleteNum;
    Log("[LuaLink] new LuaLink : %d, %d", link, data);
#endif
    return link;
}

void LuaLink::Release()
{
#ifdef EDUI_TEST_NEW_DELETE
    --m_newdeleteNum;
    Log("[LuaLink] delete LuaLink : %d, %d, %s", this, m_cobj, this->GetName());
#endif
    delete this;
}

LuaLink::LuaLink(Link* link) : LuaLabel(link)
{}

LuaLink::~LuaLink()
{}

//----------------------------------------//

//----------------------------------------//

void LuaLink::Register(LuaState *L)
{
    LuaObject obj = LuaHelperNS::AddToMetas(L, "Link", "Label");
    obj.SetObject("__index", obj);
    obj.RegisterDirect("__NewCObj__", &LuaLink::GetInterface);

}

#undef CObjPtr

EDUI_NAMESPACE_END

#endif